<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <body>

        <ui:composition template="./TemplatePrincipal.xhtml">

            <ui:define name="top">
                <h:form>
                    <p:commandButton update="panel,display" icon="ui-icon-triangle-1-w" action="AssistanceList" title="Atras" ajax="false"/>
                    <p:commandButton update="panel,display" icon="ui-icon-home" action="MenuPrincipal" title="Menu Principal" ajax="false"/>
                </h:form>
            </ui:define>

            <ui:define name="left">
            </ui:define>

            <ui:define name="right">
            </ui:define>

            <ui:define name="content">
                <f:view>
                    <h:form>
                        <p:panel header="Asistencia Create/Edit" footer="Los campos con asterisco * son obligatorios." toggleable="true">
                            <h:panelGrid columns="2">
                                <h:outputLabel value="Curso:" for="idCurso" />
                                <h:selectOneMenu id="idCurso" value="#{assistanceBean.idCursoSeleccionado}" title="IdCurso" required="true" requiredMessage="The IdCurso field is required.">
                                    <!-- TODO: update below reference to list of available items-->
                                    <f:selectItems value="#{gradeBean.lista}" var="item" itemLabel="#{item.grado} #{item.grupo} #{item.idMaestro}" itemValue="#{item.id}"/>
                                </h:selectOneMenu>
                            </h:panelGrid>
                        </p:panel>
                        <p:commandButton update="panel,display" icon="ui-icon-check" action="AssistanceCreateEdit" value="Aceptar" ajax="false" actionListener="#{assistanceBean.mostrarContenido}"/>
                    </h:form>
                    <br/>
                    <br/>

                    <h:form rendered="#{assistanceBean.visible}">
                        <p:panel header="Lista Alumnos">
                            <p:outputLabel value="No. Control Alumno " for="clave"/>
                            <p:inputMask mask="999-999" id="clave" value="#{assistanceBean.noControlAlumno}"/>
                            <p:commandButton  update="panel,display" icon="ui-icon-plusthick" action="AssistanceCreateEdit" value="Agregar" actionListener="#{assistanceBean.agregarAlumno}" ajax="false"/>
                            <br/>
                            <br/>

                            <p:dataTable value="#{assistanceBean.listAlumnos}" var="item">
                                <p:column>
                                    <f:facet name="header">
                                        <p:outputLabel value="No Control"/>
                                    </f:facet>
                                    <p:outputLabel value="#{item.nocontrol}"/>
                                </p:column>
                                <p:column>
                                    <f:facet name="header">
                                        <p:outputLabel value="Nombre"/>
                                    </f:facet>
                                    <p:outputLabel value="#{item.nombre}"/>
                                </p:column>
                                <p:column>
                                    <f:facet name="header">
                                        <p:outputLabel value="Apellido Paterno"/>
                                    </f:facet>
                                    <p:outputLabel value="#{item.APaterno}"/>
                                </p:column>
                                <p:column>
                                    <f:facet name="header">
                                        <p:outputLabel value="Apellido Materno"/>
                                    </f:facet>
                                    <p:outputLabel value="#{item.AMaterno}"/>
                                </p:column>
                                <p:column>
                                    <f:facet name="header">
                                        <p:outputLabel value="Grado"/>
                                    </f:facet>
                                    <p:outputLabel value="#{item.grado}"/>
                                </p:column>
                                <p:column>
                                    <f:facet name="header">
                                        <p:outputLabel value="Grupo"/>
                                    </f:facet>
                                    <p:outputLabel value="#{item.grupo}"/>
                                </p:column>
                                <p:column>
                                    <f:facet name="header">
                                        <p:outputLabel/>
                                    </f:facet>
                                    <center>
                                        <p:commandButton update="panel,display" icon="ui-icon-trash" title="Eliminar"
                                                         actionListener="#{assistanceBean.eliminarAlumnoLista}" ajax="false"/>
                                    </center> 
                                </p:column>
                            </p:dataTable>
                            <br/>
                            <p:commandButton update="panel,display" icon="ui-icon-check" value="Aceptar" action="AssistanceConfirm" ajax="false"/>
                            <p:commandButton update="panel,display" icon="ui-icon-closethick" value="Cancelar" action="AssistanceList" ajax="false" immediate="true"/>
                        </p:panel>
                    </h:form>
                </f:view>
            </ui:define>

        </ui:composition>

    </body>
</html>
